<?php

include_once APPLICATION_DIR.'/application/model/object/RzPointSaleTO.class.php';
include_once APPLICATION_DIR.'/application/model/dao/stmt/mysqlo/PointSaleStmt.class.php';
include_once APPLICATION_DIR.'/application/model/business/validator/utils/ErrorMessage.class.php';
include_once APPLICATION_DIR.'/application/model/business/validator/impl/point_sale/CreatePointSaleValidation.class.php';

class PointSaleRM extends RzPointSaleTO implements IActionValidation {
    
    const ENABLED = '';
    public $CITY_NAME;
    public $COUNTRY_NAME;
    private $errorMessage;
    
    public function createPointSale() {
        $this->errorMessage = new ErrorMessage();
        $validation = new CreatePointSaleValidation($this,$this);
        if($validation->checkValid()){
            $this->ENABLED = PointSaleRM::ENABLED;
            return parent::insert($this);
        }
        return false;
    }
    
    public function updatePointSale(){
        $this->errorMessage = new ErrorMessage();
        $validation = new CreatePointSaleValidation($this,$this);
        if($validation->checkValid()){
            return $this->save();
        }
        return false;
    }

    public function checkValid() {
        return true;
    }
    
    public function getErrorMessage() {
        return $this->errorMessage;
    }
    
    public function findAllValidPointSale(){
        $query = $this->point_sale_stmt->prepareSelectAllValidPointSale();
        $this->prepareData($query);
        $this->exec();
    }
}

